package com.yixiu.study.juc.queue;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * @CalssName T01_ConcurrentQueue
 * @Description
 * @Author yixiu
 * @Date 2021/6/29 9:32
 * @Verison 1.0
 **/
public class T01_ConcurrentQueue {

    public static void main(String[] args) {
        Queue<String> strs = new ConcurrentLinkedQueue<>();
//        Queue<String> strs = new ConcurrentLinkedDeque<>();//双端队列

        for (int i = 0; i < 10; i++) {
//            strs.add("a" + i);//添加失败，直接抛异常
            strs.offer("a" + i);//是否添加成功返回boolean值
        }

        System.out.println(strs);

        System.out.println(strs.size());

        System.out.println(strs.poll());
        System.out.println(strs.size());

        System.out.println(strs.peek());
        System.out.println(strs.size());
    }

}
